﻿using Abp.AspNetCore.Mvc.Controllers;
using Batman.Cms.Core.Models.Mvc;
using Batman.Jianbei.Forum.Services.Posts;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Batman.Jianbei.Forum.Areas.Forum
{
    [Area("Forum")]
    public class FavoriteController : AbpController
    {
        public PostTintCollection PostTintCollection { get; set; }

        /// <summary>
        /// （取消）收藏
        /// </summary>
        /// <param name="postId"></param>
        /// <returns></returns>
        [Authorize]
        public IActionResult PostFavorite(string postId)
        {
            bool exists = PostTintCollection.HasHisFavorite(User, postId);
            if (!exists)
                PostTintCollection.AddHisFavorite(User, postId);
            else
                PostTintCollection.RemoveHisFavorite(User, postId);

            return Json(new ResponseBase(true));
        }
    }
}
